<template>
  <div>
    <!-- 无id时, 可以使用index(反正也是就地更新) -->
    <div style="display: inline-block" v-for="item in arr">
      <input v-model="num" type="checkbox" :value="item" />
      <span>{{ item }}</span>
    </div>
    <p>你选中的元素, 累加的值和为:{{sum}}</p>
    <hr>
  </div>
</template>

<script>
export default {
  data() {
    return {
      arr: [1, 3, 10, 9, 50, 30, 56, 70],
      num: []
    }
  },
  computed: {
    sum(){
      return this.num.reduce((old, item) => old += item, 0)
    }
  }
};
</script>